/*
 * Copyright (C) Francisco Morero Peyrona. All rights reserved.
 *
 * This software is published under the terms of Open Source
 * License version 1.1, a copy of which has been included with this
 * distribution in the License.txt file.
 */

package jdbcmanager.swing;

import javax.swing.*;
import java.beans.*;

import jdbcmanager.app.*;

/**
 * A small improvement over JInternalFrame.
 * 
 * <ul>
 *   <li> Does not throws VetoableException when invoking setSelected().
 *   <li> Adds restore() method
 * </ul>
 * 
 * @author Francisco Morero Peyrona
 */
public class JxInternalFrame extends JInternalFrame
{
   public JxInternalFrame()
   {
      this( null );
   }
   
   public JxInternalFrame( String sTitle )
   {
      super( sTitle, true, true, true, true );
   }
   
   public void restore()
   {
      try
      {
         if( isIcon() || isMaximum() )
         {                        // To restore it must:
            setMaximum( true );   //   1st maximize
            setMaximum( false );  //   2nd restore
         }
      }
      catch( PropertyVetoException exc )
      {
         App.showDebugException( exc );
      }
   }
   
   public void setSelected( boolean bSelected )
   {
      try
      {
         super.setSelected( bSelected );
      }
      catch( PropertyVetoException exc )
      {
         App.showDebugException( exc );
      }
   }
}